export function graphicManage(){
    this.allGraphics = {};//所有图元对象
    this.allParam = {};//所有添加图元的数据
}
graphicManage.prototype = {
    //存储图元对象
    setGraphic(id,graphic){
        this.allGraphics[id] = graphic;
        //链式调用
        return this;
    },
    //获取图元对象
    getGraphic(id){
        return this.allGraphics[id];
    },
    //批量获取图元对象
    getMoreGraphic(ids){
        let rg = [];
        ids.map((item,index)=>{
            rg.push(this.allGraphics[item]);
        })
        return rg;
    },
    //删除图元时,同时删除id
    removeGraphic(id){
        delete this.allGraphics[id];
    },
    //判断id是否重复
    isRepetition(id){
        return !!this.allGraphics[id];
    },
    //设置图元数据
    setGraphicParam(id,obj){
        this.allParam[id] = obj;
        //链式调用
        return this;
    },
    //获取单个图元数据
    getGraphicParam(id){
        return this.allParam[id];
    },
    //批量获取图元数据
    getMoreGraphicParam(ids){
        let ap = [];
        ids.map((item,index)=>{
            ap.push(this.allParam[item]);
        })
        return ap;
    },
    //清空所有缓存数据
    clearAll(){
        this.allGraphics = {};
        this.allParam = {};
    }
}